package com.example.bilibiliprojectspringboot.controller;


import com.example.bilibiliprojectspringboot.model.entity.VideoInfo;
import com.example.bilibiliprojectspringboot.result.Result;
import com.example.bilibiliprojectspringboot.service.VideoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/videos")
@Tag(name="video控制器")
public class VideoController {

  @Autowired
  VideoService videoService;

  @Operation(summary = "按页获取推荐界面视频数据")
  @GetMapping("/page/{pageNum}/{pageSize}")
  public Result selectPageVideo(@PathVariable Integer pageNum, @PathVariable Integer pageSize){
    PageHelper.startPage(pageNum, pageSize);
    List<VideoInfo> list = videoService.selectAllVideoPublisherTimeDesc();
    return Result.success(new PageInfo<>(list));
  }

  @Operation(summary = "根据videoInfo插入视频信息")
  @PostMapping
  public Result insertVideoByObject(){
    return Result.success();
  }

}
